package com.hna.face.controller.business;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.hna.face.model.FaceAcls;
import com.hna.face.model.FaceRecognizeResult;
import com.hna.face.model.PageInfo;
import com.hna.face.service.IFaceRecognizeResultService;

@Controller
public class WarningController {

	@Autowired
	private IFaceRecognizeResultService service;

	@RequestMapping("/warn/index")
	private String index() {
		return "pages/warn/index";
	}

	@RequestMapping(value = "/warn/list", method = RequestMethod.POST)
	@ResponseBody
	private Map<String, Object> list(PageInfo pageInfo) {
		Map<String, Object> res = new HashMap<>();
		try {
			EntityWrapper<FaceRecognizeResult> wrapper = new EntityWrapper<>();
			wrapper.ne("result", 1);
			wrapper.orderBy("create_time", false);

//			Page<FaceRecognizeResult> page = new Page<>(pageInfo.getPage(), pageInfo.getRows());
//			Page<FaceRecognizeResult> aclsList = service.selectPage(page, wrapper);
			List<FaceRecognizeResult> list = service.selectList(wrapper);
			res.put("rows", list);
			res.put("total", list.size());
			res.put("success", "true");
			return res;
		} catch (Exception e) {
			res.put("success", "false");
			return res;
		}
	}

}
